#pragma once
#include <string>
#include <iosfwd>

class CMediaTypes;

namespace MkvParser
{

class Track;
class Block;

class Stream
{
    Stream(const Stream&);
    Stream& operator=(const Stream&);

public:
    virtual ~Stream();
    void Init();
    
    std::wstring GetId() const;  //IPin::QueryId
    std::wstring GetName() const;  //IPin::QueryPinInfo
    virtual void GetMediaTypes(CMediaTypes&) const = 0;
    virtual HRESULT QueryAccept(const AM_MEDIA_TYPE*) const = 0;
    virtual HRESULT UpdateAllocatorProperties(ALLOCATOR_PROPERTIES&) const = 0;

#if 0  //TODO: use this for incremental loading
    virtual HRESULT PopulateSample(IMediaSample*, __int64&) = 0;
#endif

    virtual long GetBufferSize() const = 0;
    virtual HRESULT PopulateSample(IMediaSample*) = 0;    

    __int64 GetDuration() const;
    __int64 GetCurrPosition() const;
    __int64 GetStopPosition() const;
    __int64 GetCurrTime() const;
    __int64 GetStopTime() const;

    //NOTE: moved from stream to outpin
    //HRESULT GetAvailable(LONGLONG*, LONGLONG*) const;

    //NOTE: too inefficient
    //void LoadCurrPosition(LONGLONG, DWORD, __int64& parse_result);

    void SetCurrPosition(LONGLONG, DWORD);
    void SetStopPosition(LONGLONG, DWORD);
    void SetStopPositionEOS();

protected:
    explicit Stream(Track*);    
    Track* const m_pTrack;
    bool m_bDiscontinuity;
    const Block* m_pCurr;
    const Block* m_pStop;
    LONGLONG m_baseTime;  //absolute, and scaled

    virtual std::wostream& GetKind(std::wostream&) const = 0;

};

}  //end namespace MkvParser
